package com.example.leero.graduation.adapter;

import android.content.Context;
import android.text.format.DateUtils;

import com.example.leero.graduation.R;
import com.example.leero.graduation.Util.DateUtil;
import com.example.leero.graduation.model.IntegralRecord;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

/**
 * Created by Leero on 2017-6-4.
 */

public class IntegralAdapter extends CommonAdapter<IntegralRecord> {
    private Context mContext;

    public IntegralAdapter(Context context, int layoutId, List<IntegralRecord> datas) {
        super(context, layoutId, datas);
        this.mContext = context;
    }

    @Override
    protected void convert(ViewHolder holder, IntegralRecord integralRecord, int position) {
        holder.setText(R.id.tv_change, "+" + integralRecord.variable + " 积分");
        holder.setText(R.id.tv_source, "来源: " + getSource(integralRecord.source_type));
        holder.setText(R.id.tv_date, DateUtil.getDateStringFromTZ(integralRecord.created_at));
        holder.setText(R.id.tv_time, DateUtil.getDateStringFromTZ2T(integralRecord.created_at));
    }

    private String getSource(int type) {
        if (type == 1) {
            return "签到";
        } else if(type == 2) {
            return "发布活动";
        } else if (type == 3){
            return "参与活动";
        }
        return "";
    }
}
